load("@fbcode_macros//build_defs/lib:rust_oss.bzl", "rust_oss")
load("@fbsource//tools/build_defs:rust_library.bzl", "rust_library")

oncall("scm_server_infra")

rust_library(
    name = "sql_ext",
    srcs = glob([
        "src/**/*.rs",
    ]),
    named_deps = {
        "bincode": "fbsource//third-party/rust:bincode-2",
    } | ({} if rust_oss.is_oss_build() else {
        "mononoke_xdb_telemetry_logger": "//dsi/logger/configs/MononokeXdbTelemetryLoggerConfig:mononoke_xdb_telemetry_rust_logger",
    }),
    test_deps = [
        "fbsource//third-party/rust:assert_matches",
    ] + ([] if rust_oss.is_oss_build() else [
        "fbsource//third-party/rust:pretty_assertions",
        "fbsource//third-party/rust:tempfile",
        "//common/rust/shed/sql:sql_tests_lib",
        "//common/rust/shed/fbinit:fbinit-tokio",
        "//eden/mononoke/common/metadata:metadata",
        "//eden/mononoke/mononoke_macros:mononoke_macros",
        "//dsi/logger/rust/mock_transport:mock_transport",
        "//dsi/logger/configs/MononokeXdbTelemetryLoggerConfig:log_entry-rust",
    ]),
    deps = ([
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:async-trait",
        "fbsource//third-party/rust:tracing",
        "fbsource//third-party/rust:base64",
        "fbsource//third-party/rust:bytes",
        "fbsource//third-party/rust:paste",
        "//eden/mononoke/mononoke_types:mononoke_types",
        "fbsource//third-party/rust:itertools",
        "fbsource//third-party/rust:maplit",
        "fbsource//third-party/rust:strum",
        "fbsource//third-party/rust:paste",
        "//common/rust/shed/futures_stats:futures_stats",
        "fbsource//third-party/rust:vec1",
        "fbsource//third-party/rust:serde",
        ":sql_ext_proc_macros",
        "fbsource//third-party/rust:serde_cbor",
        "fbsource//third-party/rust:derivative",
        "//eden/mononoke/common/scuba_ext:scuba_ext",
        "fbsource//third-party/rust:serde_json",
        "fbsource//third-party/rust:tokio",
        "fbsource//third-party/rust:tracing",
        "fbsource//third-party/rust:rusqlite",
        "fbsource//third-party/rust:twox-hash",
        "//common/rust/shed/cloned:cloned",
        "//common/rust/mysql:mysql_client",
        "//common/rust/shed/borrowed:borrowed",
        "//common/rust/shed/fbinit:fbinit",
        "//common/rust/shed/justknobs_stub:justknobs",
        "//common/rust/shed/memcache_stub:memcache",
        "//common/rust/shed/sql:sql",
        "//common/rust/shed/futures_retry:futures_retry",
        "//common/rust/shed/stats:stats",
        "//dba/myadmin/if:if-myadmin-rust",
        "//dba/myadmin/if:if-myadmin-rust-srclients",
        "fbsource//third-party/rust:thiserror",
        "//eden/mononoke/common/rust/sql_ext/sql_query_telemetry:sql_query_telemetry",
        "//eden/mononoke/common/rust/caching_ext:caching_ext",
        "//eden/mononoke/repo_attributes/sql_query_config:sql_query_config",
        "//eden/scm/lib/clientinfo:clientinfo",
        "//common/rust/shed/sql:sql_common",
    ] + ([] if rust_oss.is_oss_build() else [
        "fbsource//third-party/rust:aws-config",
        "fbsource//third-party/rust:aws-sdk-secretsmanager",
        "fbsource//third-party/rust:futures",
        "fbsource//third-party/rust:once_cell",
        "//common/rust/fbwhoami:fbwhoami",
        "//common/rust/build_info:build_info",
        "//common/rust/shed/hostname:hostname",
        "fbsource//third-party/rust:vec1",
        "//common/rust/shed/stats:stats",
        "fbsource//third-party/rust:mysql_async",
        "//eden/mononoke/common/time_measuring:time_measuring",
    ])) + [
        "//dba/myadmin/if:if-myadmin-rust-clients",
    ],
)

rust_library(
    name = "sql_ext_proc_macros",
    srcs = glob([
        "proc_macros/**/*.rs",
    ]),
    autocargo = {
        "cargo_toml_dir": "proc_macros",
    },
    proc_macro = True,
    deps = [
        "fbsource//third-party/rust:quote",
        "fbsource//third-party/rust:syn1",
    ],
)
